<?php

use Phalcon\Mvc\Model\Validator\Email as Email;

class ClientInfoSuggests extends \Phalcon\Mvc\Model
{

    public $latlng;

    public $id;
    /**
     *
     * @var integer
     */
    public $company_id;

    /**
     *
     * @var string
     */
    public $name;

    /**
     *
     * @var string
     */
    public $about;

    /**
     *
     * @var string
     */
    public $city;

    /**
     *
     * @var string
     */
    public $location;

    /**
     *
     * @var string
     */
    public $contact_no;

    /**
     *
     * @var string
     */
    public $email;

    /**
     *
     * @var string
     */
    public $date_created;

    /**
     *
     * @var string
     */
    public $date_modified;

    /**
     *
     * @var string
     */
    public $profile_pic;

    /**
     *
     * @var double
     */
    public $views;

    /**
     *
     * @var integer
     */
    public $status;

    /**
     *
     * @var double
     */
    public $noofworkers;

    /**
     *
     * @var integer
     */
    public $admin_id;

    /**
     *
     * @var integer
     */
    public $suggestor_id;

    /**
     * Validations and business logic
     */

    /**
     * Independent Column Mapping.
     */
    public function columnMap()
    {
        return array(
            'company_id' => 'company_id', 
            'name' => 'name', 
            'about' => 'about', 
            'city' => 'city', 
            'location' => 'location', 
            'contact_no' => 'contact_no', 
            'email' => 'email', 
            'date_created' => 'date_created', 
            'date_modified' => 'date_modified', 
            'profile_pic' => 'profile_pic', 
            'views' => 'views', 
            'status' => 'status', 
            'noofworkers' => 'noofworkers', 
            'admin_id' => 'admin_id', 
            'suggestor_id' => 'suggestor_id',
            "id" => "id",
            "latlng"=>"latlng"
        );
    }

    public function listSuggestEdit()
    {
        $phql = "SELECT ci.*,cis.* FROM ClientInfoSuggests cis
                 LEFT JOIN ClientInfo ci ON ci.id = cis.company_id 
                 WHERE cis.status = 0
                 ORDER BY cis.date_created DESC";
        $data = $this->modelsManager->executeQuery($phql);
        return $data;
    }
    public function beforeValidationOnCreate()
    {
        $this->date_created = CURR_DATE;
        $this->status = 0;

    }


}
